// K&R book. p33.

#include <stdio.h>
#include <stdlib.h> // Use function atoi().

int atoix(char s[]);

int main()
{
    char line[] = "1992";

    printf("atoix Number is %d\n", atoix(line));

    printf("atoi Number is %d\n", atoi(line));

    return 0;
}

int atoix(char s[])
{
    int i;
    int n = 0;

    for (i = 0; s[i] >= '0' && s[i] <= '9'; i++)
        n = n * 10 + (s[i] - '0');

    return n;
}